{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# Setup constants.\n",
    "PROJECT_NUM = '1064712527705'                 # CHANGE THIS\n",
    "STORAGE_BUCKET = 'papi-bucket'                # CHANGE THIS\n",
    "TRAINING_DATA_FILE = 'sample/train.csv'       # CHANGE THIS\n",
    "TAXIFARE_CLASSIFICATION_MODEL_ID = 'taxifare_classification'\n",
    "TAXIFARE_REGRESSION_MODEL_ID = 'taxifare_regression'\n",
    "CLASSIFICATION_MODEL_TYPE = 'CLASSIFICATION'\n",
    "REGRESSION_MODEL_TYPE = 'REGRESSION'\n",
    "TRAINING_DATA_FILE_LOCATION = STORAGE_BUCKET + '/' + TRAINING_DATA_FILE"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "codeCollapsed": false,
    "collapsed": false,
    "hiddenCell": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Basic predict call to hosted model: {u'kind': u'prediction#output', u'outputLabel': u'positive', u'id': u'sample.sentiment', u'selfLink': u'https://www.googleapis.com/prediction/v1.6/projects/414649711441/hostedmodels/sample.sentiment/predict', u'outputMulti': [{u'score': u'0.784671', u'label': u'positive'}, {u'score': u'0.186649', u'label': u'negative'}, {u'score': u'0.028680', u'label': u'neutral'}]}\n"
     ]
    }
   ],
   "source": [
    "# Sample calls to predict from hosted models in Predictions API.\n",
    "from googleapiclient.discovery import build\n",
    "from oauth2client.client import GoogleCredentials\n",
    "import time\n",
    "\n",
    "CREDENTIALS = GoogleCredentials.get_application_default()\n",
    "PREDICTION_SERVICE = build('prediction', 'v1.6', credentials=CREDENTIALS)\n",
    "HOSTED_MODELS_PROJECT_NUM = '414649711441'\n",
    "HOSTED_MODEL_NAME = 'sample.sentiment'\n",
    "\n",
    "body = {'input': {'csvInstance': ['hello how are you today']}}\n",
    "result = PREDICTION_SERVICE.hostedmodels().predict( project=HOSTED_MODELS_PROJECT_NUM, hostedModelName=HOSTED_MODEL_NAME, body=body ).execute()\n",
    "\n",
    "print 'Basic predict call to hosted model:', result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "codeCollapsed": false,
    "collapsed": false,
    "hiddenCell": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Call to delete the model in case it is still around from a previous run: \n"
     ]
    }
   ],
   "source": [
    "# Delete trained models in Predictions API if necessary to showcase recreated them.\n",
    "result = PREDICTION_SERVICE.trainedmodels().delete( project=PROJECT_NUM, id=TAXIFARE_CLASSIFICATION_MODEL_ID ).execute()\n",
    "result = PREDICTION_SERVICE.trainedmodels().delete( project=PROJECT_NUM, id=TAXIFARE_REGRESSION_MODEL_ID ).execute()\n",
    "\n",
    "print 'Call to delete the model in case it is still around from a previous run:', result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Call to insert a new classification model based on training data: {u'kind': u'prediction#training', u'id': u'taxifare_classification', u'selfLink': u'https://www.googleapis.com/prediction/v1.6/projects/1064712527705/trainedmodels/taxifare_classification', u'storageDataLocation': u'papi-bucket/sample/train.csv'}\n"
     ]
    }
   ],
   "source": [
    "# Insert (analyze, train, deploy) new classification model in Predictions API.\n",
    "body = {\n",
    "  'id': TAXIFARE_CLASSIFICATION_MODEL_ID,\n",
    "  'storageDataLocation': TRAINING_DATA_FILE_LOCATION,\n",
    "  'modelType': CLASSIFICATION_MODEL_TYPE,\n",
    "}\n",
    "result = PREDICTION_SERVICE.trainedmodels().insert( project=PROJECT_NUM, body=body ).execute()\n",
    "\n",
    "print 'Call to insert a new classification model based on training data:', result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Call to insert a new regression model based on training data: {u'kind': u'prediction#training', u'id': u'taxifare_regression', u'selfLink': u'https://www.googleapis.com/prediction/v1.6/projects/1064712527705/trainedmodels/taxifare_regression', u'storageDataLocation': u'papi-bucket/sample/train.csv'}\n"
     ]
    }
   ],
   "source": [
    "# Insert (analyze, train, deploy) new regression model in Predictions API.\n",
    "body = {\n",
    "  'id': TAXIFARE_REGRESSION_MODEL_ID,\n",
    "  'storageDataLocation': TRAINING_DATA_FILE_LOCATION,\n",
    "  'modelType': REGRESSION_MODEL_TYPE,\n",
    "}\n",
    "result = PREDICTION_SERVICE.trainedmodels().insert( project=PROJECT_NUM, body=body ).execute()\n",
    "\n",
    "print 'Call to insert a new regression model based on training data:', result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Status is:  RUNNING \tCurrent delay:  1\n",
      "Status is:  RUNNING \tCurrent delay:  2\n",
      "Status is:  RUNNING \tCurrent delay:  4\n",
      "Status is:  RUNNING \tCurrent delay:  8\n",
      "Status is:  RUNNING \tCurrent delay:  16\n",
      "Status is:  RUNNING \tCurrent delay:  32\n",
      "Status is:  RUNNING \tCurrent delay:  32\n",
      "Status is:  RUNNING \tCurrent delay:  32\n"
     ]
    }
   ],
   "source": [
    "# Get newly created classification model in Predictions API.\n",
    "result = PREDICTION_SERVICE.trainedmodels().get( project=PROJECT_NUM, id=TAXIFARE_CLASSIFICATION_MODEL_ID ).execute()\n",
    "initial_delay = 1\n",
    "while (result['trainingStatus'] != 'DONE'):\n",
    "  print 'Status is: ', result['trainingStatus'], '\\tCurrent delay: ', initial_delay\n",
    "  time.sleep(initial_delay)\n",
    "  if (initial_delay < 30):\n",
    "    initial_delay = initial_delay * 2\n",
    "  result = PREDICTION_SERVICE.trainedmodels().get( project=PROJECT_NUM, id=TAXIFARE_CLASSIFICATION_MODEL_ID ).execute()\n",
    "\n",
    "print 'Call to get the new classification model that was just created: ', result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Call to get the new regression model that was just created:  {u'kind': u'prediction#training', u'created': u'2017-03-23T12:56:19.738Z', u'trainingStatus': u'DONE', u'modelInfo': {u'numberInstances': u'22401', u'meanSquaredError': u'126.48', u'modelType': u'regression'}, u'trainingComplete': u'2017-03-23T13:00:44.360Z', u'id': u'taxifare_regression', u'selfLink': u'https://www.googleapis.com/prediction/v1.6/projects/1064712527705/trainedmodels/taxifare_regression'}\n"
     ]
    }
   ],
   "source": [
    "# Get newly created regression model in Predictions API.\n",
    "result = PREDICTION_SERVICE.trainedmodels().get( project=PROJECT_NUM, id=TAXIFARE_REGRESSION_MODEL_ID ).execute()\n",
    "initial_delay = 1\n",
    "while (result['trainingStatus'] != 'DONE'):\n",
    "  print 'Status is: ', result['trainingStatus'], '\\tCurrent delay: ', initial_delay\n",
    "  time.sleep(initial_delay)\n",
    "  if (initial_delay < 30):\n",
    "    initial_delay = initial_delay * 2\n",
    "  result = PREDICTION_SERVICE.trainedmodels().get( project=PROJECT_NUM, id=TAXIFARE_REGRESSION_MODEL_ID ).execute()\n",
    "\n",
    "print 'Call to get the new regression model that was just created: ', result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "codeCollapsed": false,
    "collapsed": false,
    "hiddenCell": false
   },
   "outputs": [],
   "source": [
    "# Measure error in newly created models in Predictions API.\n",
    "import math\n",
    "validation_data = { # This is a sample of a larger set of validation data. The key is the expected result, and the value is the csv input for a prediction.\n",
    "  '12.1': 'Sun,0,-73.984685,40.769262,-73.991065,40.728145,5.0,2009-05-31 00:48:00.000000-73.984740.769340.7281-73.9911',\n",
    "  '15.3': 'Sun,0,-74.006927,40.739993,-73.950025,40.773403,1.0,2009-05-31 00:48:00.000000-74.006940.7440.7734-73.95',\n",
    "  '9.3': 'Sun,0,-73.977345,40.779387,-73.97615,40.778867,1.0,2009-05-31 00:48:00.000000-73.977340.779440.7789-73.9762',\n",
    "  '12.5': 'Sun,0,-73.97136,40.794413,-73.99623,40.74524,1.0,2009-05-31 00:48:00.000000-73.971440.794440.7452-73.9962',\n",
    "  '6.1': 'Sun,0,-73.997642,40.763853,-73.99485,40.750282,1.0,2009-05-31 00:48:00.000000-73.997640.763940.7503-73.9948',\n",
    "  '14.9': 'Sun,0,-74.004538,40.742202,-73.955823,40.773485,1.0,2009-05-31 00:48:00.000000-74.004540.742240.7735-73.9558',\n",
    "  '11.7': 'Sun,0,-74.000589,40.73731,-73.985902,40.692725,1.0,2012-06-10 00:46:17.000000-74.000640.737340.6927-73.9859',\n",
    "  '6.5': 'Sun,0,-73.995432,40.72114,-73.992403,40.719745,1.0,2009-05-31 00:48:00.000000-73.995440.721140.7197-73.9924',\n",
    "  '5.3': 'Sun,0,-73.945033,40.779203,-73.952037,40.766802,1.0,2009-05-31 00:48:00.000000-73.94540.779240.7668-73.952',\n",
    "  '6.9': 'Sun,0,-73.968592,40.693262,-73.99231,40.694317,1.0,2009-05-31 00:48:00.000000-73.968640.693340.6943-73.9923',\n",
    "  '7.3': 'Sun,0,-74.004307,40.722348,-73.981768,40.73257,1.0,2009-05-31 00:48:00.000000-74.004340.722340.7326-73.9818',\n",
    "  '3.5': 'Sun,2,-73.995862,40.764342,-73.994105,40.761385,5.0,2014-04-27 02:57:00.000000-73.995940.764340.7614-73.9941',\n",
    "  '6.9': 'Sun,2,-73.979281,40.759491,-74.00226,40.751751,1.0,2010-01-03 02:03:40.000000-73.979340.759540.7518-74.0023',\n",
    "  '10.1': 'Sun,2,-73.99367,40.721015,-73.975817,40.681697,2.0,2009-12-06 02:12:00.000000-73.993740.72140.6817-73.9758',\n",
    "  '5.7': 'Sun,2,-74.002428,40.730257,-74.009255,40.738795,1.0,2009-12-06 02:12:00.000000-74.002440.730340.7388-74.0093',\n",
    "  '9.3': 'Sun,2,-74.006145,40.743685,-73.979365,40.761348,2.0,2009-12-06 02:12:00.000000-74.006140.743740.7613-73.9794',\n",
    "  '14.0': 'Sun,2,-73.939992,40.75127,-73.990035,40.741842,1.0,2014-04-27 02:57:00.000000-73.9440.751340.7418-73.99',\n",
    "  '9.5': 'Sun,2,-74.004012,40.732882,-73.990517,40.761255,3.0,2014-04-27 02:57:00.000000-74.00440.732940.7613-73.9905',\n",
    "  '12.0': 'Sun,2,-73.985962,40.722237,-73.960253,40.762042,5.0,2014-04-27 02:57:00.000000-73.98640.722240.762-73.9603',\n",
    "}\n",
    "classification_total_squared_error = 0.0\n",
    "regression_total_squared_error = 0.0\n",
    "for key, value in validation_data.iteritems():\n",
    "  values = value.split(',')\n",
    "  body = {\n",
    "    'input': {\n",
    "      'csvInstance': values\n",
    "    }\n",
    "  }\n",
    "  classification_result = PREDICTION_SERVICE.trainedmodels().predict( project=PROJECT_NUM, id=TAXIFARE_CLASSIFICATION_MODEL_ID, body=body ).execute()\n",
    "  regression_result = PREDICTION_SERVICE.trainedmodels().predict( project=PROJECT_NUM, id=TAXIFARE_REGRESSION_MODEL_ID, body=body ).execute()\n",
    "\n",
    "  expected_result = float(key)\n",
    "  classification_error = expected_result - float(classification_result['outputLabel'])\n",
    "  classification_squared_error = classification_error ** 2\n",
    "  classification_total_squared_error = classification_total_squared_error + classification_squared_error\n",
    "  regression_error = expected_result - float(regression_result['outputValue'])\n",
    "  regression_squared_error = regression_error ** 2\n",
    "  regression_total_squared_error = regression_total_squared_error + regression_squared_error\n",
    "\n",
    "count = len(validation_data)\n",
    "classification_mean_squared_error = classification_total_squared_error / count\n",
    "classification_rmse = math.sqrt(classification_mean_squared_error)\n",
    "regression_mean_squared_error = regression_total_squared_error / count\n",
    "regression_rmse = math.sqrt(regression_mean_squared_error)\n",
    "print 'Total Classification Squared Error: ', classification_total_squared_error, ' Mean Squared Error: ', classification_mean_squared_error, ' RMSE: ', classification_rmse\n",
    "print 'Total Regression Squared Error: ', regression_total_squared_error, ' Mean Squared Error: ', regression_mean_squared_error, ' RMSE: ', regression_rmse"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 101,
   "metadata": {
    "codeCollapsed": false,
    "collapsed": false,
    "hiddenCell": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Call to list all the models:  {u'items': [{u'kind': u'prediction#training', u'id': u'taxifare_classification'}, {u'kind': u'prediction#training', u'id': u'taxifare_regression'}], u'kind': u'prediction#list', u'selfLink': u'https://www.googleapis.com/prediction/v1.6/projects/1064712527705/trainedmodels/list'}\n",
      "Call to analyze the classification model:  {u'kind': u'prediction#analyze', u'errors': [{u'WARNING': u\"Too few instances for class '21.2': have 1 instance, require at least 2.\"}, {u'WARNING': u\"Too few instances for class '29.8': have 1 instance, require at least 2.\"}, {u'WARNING': u\"Too few instances for class '72.83': have 1 instance, require at least 2.\"}], u'dataDescription': {u'outputFeature': {u'text': [{u'count': u'332', u'value': u'10.0'}, {u'count': u'301', u'value': u'10.1'}, {u'count': u'589', u'value': u'10.5'}, {u'count': u'3', u'value': u'10.6'}, {u'count': u'231', u'value': u'10.9'}, {u'count': u'282', u'value': u'11.0'}, {u'count': u'207', u'value': u'11.3'}, {u'count': u'267', u'value': u'11.5'}, {u'count': u'198', u'value': u'11.7'}, {u'count': u'230', u'value': u'12.0'}, {u'count': u'187', u'value': u'12.1'}, {u'count': u'351', u'value': u'12.5'}, {u'count': u'148', u'value': u'12.9'}, {u'count': u'192', u'value': u'13.0'}, {u'count': u'177', u'value': u'13.5'}, {u'count': u'139', u'value': u'13.7'}, {u'count': u'142', u'value': u'14.0'}, {u'count': u'118', u'value': u'14.1'}, {u'count': u'230', u'value': u'14.5'}, {u'count': u'120', u'value': u'14.9'}, {u'count': u'128', u'value': u'15.0'}, {u'count': u'82', u'value': u'15.3'}, {u'count': u'102', u'value': u'15.5'}, {u'count': u'77', u'value': u'15.7'}, {u'count': u'131', u'value': u'16.0'}, {u'count': u'77', u'value': u'16.1'}, {u'count': u'182', u'value': u'16.5'}, {u'count': u'70', u'value': u'16.9'}, {u'count': u'98', u'value': u'17.5'}, {u'count': u'58', u'value': u'17.7'}, {u'count': u'84', u'value': u'18.0'}, {u'count': u'128', u'value': u'18.5'}, {u'count': u'68', u'value': u'19.0'}, {u'count': u'69', u'value': u'19.5'}, {u'count': u'40', u'value': u'2.5'}, {u'count': u'63', u'value': u'20.0'}, {u'count': u'120', u'value': u'20.5'}, {u'count': u'45', u'value': u'21.0'}, {u'count': u'1', u'value': u'21.2'}, {u'count': u'52', u'value': u'21.5'}, {u'count': u'35', u'value': u'22.0'}, {u'count': u'62', u'value': u'22.5'}, {u'count': u'44', u'value': u'23.0'}, {u'count': u'2', u'value': u'23.05'}, {u'count': u'30', u'value': u'23.5'}, {u'count': u'21', u'value': u'23.7'}, {u'count': u'45', u'value': u'24.5'}, {u'count': u'22', u'value': u'25.3'}, {u'count': u'5', u'value': u'26.27'}, {u'count': u'14', u'value': u'27.3'}, {u'count': u'10', u'value': u'27.5'}, {u'count': u'29', u'value': u'28.5'}, {u'count': u'3', u'value': u'28.83'}, {u'count': u'1', u'value': u'29.8'}, {u'count': u'183', u'value': u'3.3'}, {u'count': u'137', u'value': u'3.5'}, {u'count': u'339', u'value': u'3.7'}, {u'count': u'3', u'value': u'31.07'}, {u'count': u'3', u'value': u'31.47'}, {u'count': u'9', u'value': u'31.5'}, {u'count': u'2', u'value': u'31.85'}, {u'count': u'9', u'value': u'32.1'}, {u'count': u'9', u'value': u'33.3'}, {u'count': u'5', u'value': u'33.5'}, {u'count': u'7', u'value': u'33.83'}, {u'count': u'12', u'value': u'34.5'}, {u'count': u'9', u'value': u'34.9'}, {u'count': u'4', u'value': u'36.67'}, {u'count': u'7', u'value': u'38.83'}, {u'count': u'212', u'value': u'4.0'}, {u'count': u'499', u'value': u'4.1'}, {u'count': u'890', u'value': u'4.5'}, {u'count': u'641', u'value': u'4.9'}, {u'count': u'3', u'value': u'41.3'}, {u'count': u'57', u'value': u'45.0'}, {u'count': u'39', u'value': u'49.57'}, {u'count': u'91', u'value': u'49.8'}, {u'count': u'395', u'value': u'5.0'}, {u'count': u'684', u'value': u'5.3'}, {u'count': u'509', u'value': u'5.5'}, {u'count': u'648', u'value': u'5.7'}, {u'count': u'44', u'value': u'52.0'}, {u'count': u'104', u'value': u'57.33'}, {u'count': u'462', u'value': u'6.0'}, {u'count': u'660', u'value': u'6.1'}, {u'count': u'1101', u'value': u'6.5'}, {u'count': u'618', u'value': u'6.9'}, {u'count': u'462', u'value': u'7.0'}, {u'count': u'594', u'value': u'7.3'}, {u'count': u'429', u'value': u'7.5'}, {u'count': u'529', u'value': u'7.7'}, {u'count': u'1', u'value': u'72.83'}, {u'count': u'427', u'value': u'8.0'}, {u'count': u'484', u'value': u'8.1'}, {u'count': u'770', u'value': u'8.5'}, {u'count': u'379', u'value': u'8.9'}, {u'count': u'366', u'value': u'9.0'}, {u'count': u'362', u'value': u'9.3'}, {u'count': u'320', u'value': u'9.5'}, {u'count': u'328', u'value': u'9.7'}], u'numeric': {u'count': u'22401', u'variance': u'92.06', u'mean': u'11.35'}}, u'features': [{u'index': u'0', u'categorical': {u'count': u'22401', u'values': [{u'count': u'3077', u'value': u'Fri'}, {u'count': u'3717', u'value': u'Mon'}, {u'count': u'2785', u'value': u'Sat'}, {u'count': u'3734', u'value': u'Sun'}, {u'count': u'3259', u'value': u'Thu'}, {u'count': u'2536', u'value': u'Tue'}, {u'count': u'3293', u'value': u'Wed'}]}}, {u'index': u'1', u'numeric': {u'count': u'22401', u'variance': u'37.27', u'mean': u'13.45'}}, {u'index': u'2', u'numeric': {u'count': u'22401', u'variance': u'0.00', u'mean': u'-73.97'}}, {u'index': u'3', u'numeric': {u'count': u'22401', u'variance': u'0.00', u'mean': u'40.75'}}, {u'index': u'4', u'numeric': {u'count': u'22401', u'variance': u'0.00', u'mean': u'-73.97'}}, {u'index': u'5', u'numeric': {u'count': u'22401', u'variance': u'0.00', u'mean': u'40.75'}}, {u'index': u'6', u'numeric': {u'count': u'22401', u'variance': u'1.75', u'mean': u'1.71'}}, {u'index': u'7', u'text': {u'count': u'22401'}}]}, u'modelDescription': {u'modelinfo': {u'kind': u'prediction#training'}}, u'id': u'taxifare_classification', u'selfLink': u'https://www.googleapis.com/prediction/v1.6/projects/1064712527705/trainedmodels/taxifare_classification/analyze'}\n",
      "Call to analyze the regression model:  {u'dataDescription': {u'outputFeature': {u'numeric': {u'count': u'22401', u'variance': u'92.06', u'mean': u'11.35'}}, u'features': [{u'index': u'0', u'categorical': {u'count': u'22401', u'values': [{u'count': u'3077', u'value': u'Fri'}, {u'count': u'3717', u'value': u'Mon'}, {u'count': u'2785', u'value': u'Sat'}, {u'count': u'3734', u'value': u'Sun'}, {u'count': u'3259', u'value': u'Thu'}, {u'count': u'2536', u'value': u'Tue'}, {u'count': u'3293', u'value': u'Wed'}]}}, {u'index': u'1', u'numeric': {u'count': u'22401', u'variance': u'37.27', u'mean': u'13.45'}}, {u'index': u'2', u'numeric': {u'count': u'22401', u'variance': u'0.00', u'mean': u'-73.97'}}, {u'index': u'3', u'numeric': {u'count': u'22401', u'variance': u'0.00', u'mean': u'40.75'}}, {u'index': u'4', u'numeric': {u'count': u'22401', u'variance': u'0.00', u'mean': u'-73.97'}}, {u'index': u'5', u'numeric': {u'count': u'22401', u'variance': u'0.00', u'mean': u'40.75'}}, {u'index': u'6', u'numeric': {u'count': u'22401', u'variance': u'1.75', u'mean': u'1.71'}}, {u'index': u'7', u'text': {u'count': u'22401'}}]}, u'kind': u'prediction#analyze', u'modelDescription': {u'modelinfo': {u'kind': u'prediction#training'}}, u'id': u'taxifare_regression', u'selfLink': u'https://www.googleapis.com/prediction/v1.6/projects/1064712527705/trainedmodels/taxifare_regression/analyze'}\n"
     ]
    }
   ],
   "source": [
    "# Other sample calls in Predictions API (list, analyze).\n",
    "result = PREDICTION_SERVICE.trainedmodels().list( project=PROJECT_NUM ).execute()\n",
    "print 'Call to list all the models: ', result\n",
    "\n",
    "classification_result = PREDICTION_SERVICE.trainedmodels().analyze( project=PROJECT_NUM, id=TAXIFARE_CLASSIFICATION_MODEL_ID ).execute()\n",
    "regression_result = PREDICTION_SERVICE.trainedmodels().analyze( project=PROJECT_NUM, id=TAXIFARE_REGRESSION_MODEL_ID ).execute()\n",
    "\n",
    "print 'Call to analyze the classification model: ', classification_result\n",
    "print 'Call to analyze the regression model: ', regression_result"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
